#include <57header.h>

/* Usage: ./03_readloop filename */
int main(int argc, char *argv[]){
    ARGS_CHECK(argc, 2);
    int fd = open(argv[1], O_RDWR);
    ERROR_CHECK(fd, -1, "open");

    // 开始read
    char buf[4] = {0};
    int count;
    while((count = read(fd, buf, sizeof(buf) -1)) > 0){
        printf("count = %d\n",count);
        printf("buf = %.*s\n",count, buf);
        //puts(buf);
        //memset(buf, 0, sizeof(buf));    // 将buf数组的全部内容设置为空字符
    }
    close(fd);
    return 0;
}

